<?php
function showPID()
{
   $pid = posix_getpid();
   fprintf(STDOUT,"pid=%d,ppid=%d,pgid=%d,sid=%d\n",$pid,posix_getppid(),posix_getpgid($pid),posix_getsid($pid));
}

showPID();
$pid = pcntl_fork();
if ($pid>0){
    exit(0);
}
if (posix_setsid()==-1){
    echo "error";
    $errno = pcntl_errno();
    echo pcntl_strerror($errno);
}else{
    echo "会话创建成功\r\n";
}
showPID();
while (1){
    sleep(2);
}